*******Pew Research Center Poll: PEW RESEARCH CENTER May 2018 Spring 2018 Global Attitudes Survey
use "Pew Threat/Pew Data/PEW_2018_May.dta", clear

*Year
gen year=2018

keep if country==27

*CC Threat
gen CCthreat1=INTTHR_2
recode CCthreat1 ///
		(1=3 "Major threat") ///
		(2=2 "Minor threat") ///
		(3=1 "Not a threat") ///
		(else=.), ///
		gen(CCthreat)
lab var CCthreat "Climate Change Threat"
drop CCthreat1

*Party Preference
recode D_PTY_24 ///
	(1 = 1 "GOP") ///
	(3 = 3 "Independent") ///
	(2=2 "Democrat") ///
	(else=3), ///
	gen(partyid)
lab var partyid "Party Preference"

replace partyid=1 if D_PTYLEA==1
replace partyid=2 if D_PTYLEA==2
replace partyid=. if D_PTYLEA==9


*Gender
recode sex ///
	(1=0 "Male") ///
	(2=1 "Female") ///
	(else=.), ///
	gen(female)
lab var female "Female"	

*Age
gen AGE=age
replace age=. if age==99|if age==98
replace age=89 if age>=89 
lab var age "Age"

*Cohort
gen age_cohort = year-AGE
replace age_cohort=. if AGE== 98|AGE ==99
recode age_cohort ///
	(1900/1904=1 "1900-1904") ///
	(1905/1909=2 "1905-1909") ///
	(1910/1914=3 "1910-1914") ///
	(1915/1919=4 "1915-1919") ///
	(1920/1924=5 "1920-1924") ///
	(1925/1929=6 "1925-1929") ///
	(1930/1934=7 "1930-1934") ///
	(1935/1939=8 "1935-1939") ///
	(1940/1944=9 "1940-1944") ///
	(1945/1949=10 "1945-1949") ///
	(1950/1954=11 "1950-1954") ///
	(1955/1959=12 "1955-1959") ///
	(1960/1964=13 "1960-1964") ///
	(1965/1969=14 "1965-1969") ///
	(1970/1974=15 "1970-1974") ///
	(1975/1979=16 "1975-1979") ///
	(1980/1984=17 "1980-1984") ///
	(1985/1989=18 "1985-1989") ///
	(1990/1994=19 "1990-1994") ///
	(1995/1999=20 "1995-1999") ///
	(2000/2004=21 "2000-2004"), ///
	gen(cohort)
la var cohort "Age Cohort, 5 yr. intervals"

*Education
recode D_EDU_16 ///
	(1 2=1 "<HS") ///
	(3 4=2 "HS Graduate") ///
	(5=3 "Some College") ///
	(6 7 8=4 "College Graduate") ///
	(else=.), ///
	gen(education)
lab var education "Education"

*Racial Identity
recode racethn  ///
	(1=1 "White") ///
	(2=2 "Black") ///
	(3=3 "Hispanic") ///
	(4=4 "Other") ///
	(else=.), ///
	gen(race)
lab var race "Racial Identity"

*Rural Inhabitance
/*NA IN 2020
gen DENSITY=density
recode DENSITY ///
	(1=5 "Lowest density") ///
	(2=4) ///
	(3=3 "Middle density") ///
	(4=2) ///
	(5=1 "Highest density") ///
	(else=.), ///
	gen(density1)
drop density DENSITY
rename density1 density
lab var density "Population Density"
*/

encode usr, gen(rural1)
recode rural1 ///
	(2 3=0 "Sub/Urban") ///
	(1=1 "Rural") ///
	(else=.), ///
	gen(rural)
lab var rural "Rural Inhabitance"
drop rural1
	
*Southern State
recode cregion ///
	(1 2 4 = 0 "not South") ///
	(3=1 "South") ///
	(else=.), ///
	gen(south)
lab var south "Southern State"

/*
*weight
gen weight=WEIGHT
*/

*ID
rename id respid
gen id=respid+20190000

*Keep and save
keep CCthreat partyid female age ///
	education race rural south ///
	year weight id cohort
save "Pew Threat/Individual Recoded Pew Files/Pew_2018_May_Recode", replace

/*test
ologit CCthreat partyid female age education race rural south
